from django.db import models


class Contact(models.Model):
    name = models.CharField(max_length=100)
    surname = models.CharField(max_length=100)
    avatar = models.FileField(null=True, blank=True, upload_to='avatars')
    birthday = models.DateField(null=True, blank=True)


class Phone(models.Model):
    PHONE_TYPE_NONE = 0
    PHONE_TYPE_HOME = 1
    PHONE_TYPE_OFFICE = 2
    PHONE_TYPE_MOBILE = 3

    CHOICES_PHONE_TYPE = (
        (PHONE_TYPE_NONE, "Undefined"),
        (PHONE_TYPE_HOME, "Home"),
        (PHONE_TYPE_OFFICE, "Office"),
        (PHONE_TYPE_MOBILE, "Mobile"),
    )

    type = models.PositiveSmallIntegerField(choices=CHOICES_PHONE_TYPE)
    value = models.CharField(max_length=20)
    contact = models.ForeignKey('Contact')


class Address(models.Model):
    ADDRESS_TYPE_NONE = 0
    ADDRESS_TYPE_HOME = 1
    ADDRESS_TYPE_WORK = 2

    CHOICES_ADDRESS_TYPE = (
        (ADDRESS_TYPE_NONE, "Undefined"),
        (ADDRESS_TYPE_HOME, "Home"),
        (ADDRESS_TYPE_WORK, "Work"),
    )

    country = models.CharField(max_length=50, null=True, blank=True)
    city = models.CharField(max_length=50, null=True, blank=True)
    street = models.CharField(max_length=50, null=True, blank=True)
    apartment = models.CharField(max_length=10, null=True, blank=True)
    flat = models.PositiveSmallIntegerField(null=True, blank=True)
    type = models.PositiveSmallIntegerField(choices=CHOICES_ADDRESS_TYPE)
    contact = models.ForeignKey('Contact')

